home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Snippets
/
SuperSplash 1.0d1
/
sources
/
stdHighLevelApple.cp
< prev
next >
Wrap
Text File
|
1995-10-03
|
4KB
|
157 lines
/*
* stdHighLevelApple.cp
*
* SuperSplash
* ^^^^^^^^^^^
* 4 required high-level AE's
* Uses UPP's for future PowerMac compatibility
*
* © Andrew Nemeth (where applicable), Warrimoo Australia 1994, 1995
* aznemeng@zeta.org.au
*
* File created: 19 Mar 95.
* Modified: 19, 22, 27 Mar;
* 15 Jun;
* 3 Oct 95.
*/
#include "stdHighLevelApple.h" // Application High-Level AE
#include "gVariables.h" // Global variable defn & 'externs'
#include <AppleEvents.h> // High level AE
#include <gestaltEqu.h> // Gestalt
// LOCAL function prototypes…
//
static pascal OSErr doOpenApp ( AppleEvent *, AppleEvent *, long );
static pascal OSErr doOpenDoc ( AppleEvent *, AppleEvent *, long );
static pascal OSErr doPrintDoc ( AppleEvent *, AppleEvent *, long );
static pascal OSErr doQuitApp ( AppleEvent *, AppleEvent *, long );
// FILE GLOBALS
//
AEEventHandlerUPP guppOpenApp,
guppOpenDoc,
guppPrintDoc,
guppQuitApp;
// N.B. These MUST be declared as global because
// they have to be viable for the life of the
// program in native PPC apps!
void highLevelEventInit( void )
//
// Function to initialise
// 4 required AppleEvent handlers
//
{
OSErr myErr = noErr;
// Install the High Level event handlers for the 4 main AE's.
// If there's a problem with any of them, drop into Jasik Land…
guppOpenApp = NewAEEventHandlerProc( doOpenApp );
myErr = ::AEInstallEventHandler( kCoreEventClass, kAEOpenApplication,
guppOpenApp, 0L, FALSE );
if ( myErr != noErr )
{
::SysBeep(1);
::DebugStr( "\pInstall of kAEOpenApplication handler failed" );
}
guppOpenDoc = NewAEEventHandlerProc( doOpenDoc );
myErr = ::AEInstallEventHandler( kCoreEventClass, kAEOpenDocuments,
guppOpenDoc, 0L, FALSE );
if ( myErr != noErr )
{
::SysBeep(1);
::DebugStr( "\pInstall of kAEOpenDocuments handler failed" );
}
guppPrintDoc = NewAEEventHandlerProc( doPrintDoc );
myErr = ::AEInstallEventHandler( kCoreEventClass, kAEPrintDocuments,
guppPrintDoc, 0L, FALSE );
if ( myErr != noErr )
{
::SysBeep(1);
::DebugStr( "\pInstall of kAEPrintDocuments handler failed" );
}
guppQuitApp = NewAEEventHandlerProc( doQuitApp );
myErr = ::AEInstallEventHandler( kCoreEventClass, kAEQuitApplication,
guppQuitApp, 0L, FALSE );
if ( myErr != noErr )
{
::SysBeep(1);
::DebugStr( "\pInstall of kAEQuitApplication handler failed" );
}
}
pascal OSErr doOpenApp( AppleEvent * ptraeEvent,
AppleEvent * ptraeReply,
long lgRefcon )
//
// The routine called at startup.
//
{
// silence the compiler warnings!
if ( lgRefcon || ptraeEvent || ptraeReply )
NULL;
return( noErr );
}
pascal OSErr doOpenDoc( AppleEvent * ptraeEvent,
AppleEvent * ptraeReply,
long lgRefcon )
//
// Not supported. Just start app instead.
//
{
return( doOpenApp( ptraeEvent, ptraeReply, lgRefcon ) );
}
pascal OSErr doPrintDoc( AppleEvent * ptraeEvent,
AppleEvent * ptraeReply,
long lgRefcon )
//
// Print not supported by this application
//
{
// silence the compiler warnings!
if ( lgRefcon || ptraeEvent || ptraeReply )
NULL;
// exit gracefully
gptrGlobalsRec->boolDone = TRUE;
return( noErr );
}
pascal OSErr doQuitApp( AppleEvent * ptraeEvent,
AppleEvent * ptraeReply,
long lgRefcon )
//
// Functions to perform on 'quit' Apple Event.
//
{
// silence the compiler warnings!
if ( lgRefcon || ptraeEvent || ptraeReply )
NULL;
gptrGlobalsRec->boolDone = TRUE;
return( noErr );
}